<%@ page import="java.sql.*,pc.util.Utils"%>
<%
    Users user = Trader.getUser(request.getParameter("uid"));
	wstrader.task.trade.fixation.Contract task = user.trade.fixation.contract;

	if (!user.Authenticated()) {
		response.sendRedirect("logon.jsp");
		return;
	}
	((Tasks)task.getOwner()).clearFocus();
	task.setFocus(true);
	Trader.window_width = "900";
	String action="0";
	String roll="0";
	if (request.getParameter("action_id")!=null) action = request.getParameter("action_id");
	if (request.getParameter("rolling_id")!=null) roll = request.getParameter("rolling_id");	
%>

<%@include file="../header.jsp"%>

<%
	long focused_id = task.doTask();
	if (focused_id <= 0) focused_id = Utils.strToInt(action);

	String fixid="0";
	if (request.getParameter("id") != null) fixid = request.getParameter("id");

	long new_id = task.getLastID("contract_price_fixation") + 1;
	String CurYrs =task.getNew_CntFixRef();//"PF" + Utils.numberToStr(Utils.getCurYear(),0).substring(3) + "-" + new_id;
	long new_id_fut = task.getLastID("futures_contract") + 1;
	String CurYrs_fut =task.getNew_FutRef();//"FC" + Utils.numberToStr(Utils.getCurYear(),0).substring(3) + "-" + new_id;
		
	Record rc   = task.getRecord("contracts",focused_id);
	Record fixrc = task.getRecord("contract_price_fixation",Utils.strToLong(fixid));
	
%>

<link href="style.css" rel="stylesheet" type="text/css">
<script language="javascript">
function doDelete()
{
	form = document.formMain;
	doTask(2);
}

function doReport()
{
	var form = document.formMain;
	form.action_id.value="1";
	doTask(5);
}

function doRoll()
{
	var form = document.formMain;
	if (form.contracts.value > 0)
	{
		if (form.unfixed_lots.value >= 1)
		{	
			form.roll_id.value="1";
			form.action_id.value="0";
			hide("cardEntry");
			setValue("id",<%=task.getLastID("contract_roll_over") + 1%>);
			show("RollEntry");
		}
		else
		{
			alert("Contract has been fully fixed. Cannot roll over");
		}
	}
	else
	{
		alert("Please select a contract to roll over");
	}	
}

function doAddNew()
{
	var form = document.formMain;
	if (form.contracts.value > 0)
	{
		if (form.unfixed_lots.value >= 1)
		{
			setValue("id",<%=new_id%>);
			setValue("fixation_date","");
			setValue("ref_number",'<%=CurYrs%>');
			setValue("tons_fixed","0.000");
			setValue("lots_fixed","0");
			setValue("price_foreign","0.00");
			setValue("hedge_price","0.00");
			setValue("fixation_date","<%=Utils.dateToStr(Utils.today())%>");
			setValue("fut_ref_no","<%=CurYrs_fut%>");
			setValue("differential",form.cnt_differential.value);
			setValue("terminal_month",form.ter_month.value);
			form.action_id.value="1";
			form.roll_id.value="0";
			hide("rollEntry");
			show("CardEntry");
			hide("BrkId");
		}
		else
		{
			alert("You have fully fixed the contract");
		}
	}
	else
	{
		alert("Please Select A Contract");
	}
}

function doCalTons()
{
	var form = document.formMain;
	var uftons = form.unfixed_tons.value;
	var fixedlot = form.lots_fixed.value;
	var fixedton=0;
	
   	if (form.terminal_market.value == 'LIFFE') 
	{
		fixedton = fixedlot * 5;
	}
	else
	{
		fixedton = fixedlot * 17.01;
	}
	
	if (fixedton > uftons)
	{
		fixedton = uftons;
	}
	form.tons_fixed.value=formatNumber(fixedton,2,false);
}

function doCalLots()
{
	var form = document.formMain;
	var lot = 0;
	var ton = 0;
	var tm ="";
	ton=parseFloat(form.tons_fixed.value);
	tm = form.terminal_month.value;
	if (ton > 0)
	{
    	if (form.terminal_market.value == 'LIFFE') 
		{
        	lot = formatNumber((ton / 5),0,false);
			lot = lot;
		}
    	else
			{
        		lot = formatNumber((ton / 17.01),0,false);
				lot = lot;
			}
		form.lots_fixed.value = lot;
	}
	else
	{
		form.lots_fixed.value = 0;
	}
}

function doCalPrice()
{
	var form = document.formMain;
	var hprice = parseFloat(form.hedge_price.value);
	var diff =parseFloat(form.differential.value);
	var fprice =  formatNumber((hprice + diff),2,false);
	form.price_foreign.value = fprice;
}

function doRollUpdate()
{
	var form = document.formMain;
	hide("CardEntry");
	form.rolling_id.value="0";
	doTask(3);	
}

function doUpdate()
{	
	var form = document.formMain;
	if (form.tons_fixed.value > 0)
	{
		if (form.lots_fixed.value > 0)
		{
			if (form.hedge_price.value > 0)
			{
				if (form.fixation_type.value !="")
				{
					if (form.fixation_date.value !="")
					{
						hide("CardEntry");
						form.action_id.value="0";
						doTask(1);
					}
					else
					{
						alert("Fixation Date Cannot Be Empty");
					}
				}
				else
				{
					alert("Fixation Type Cannot Be Empty");
				}
			}
			else
			{
				alert("Hedge Price Cannot Be Empty");
			}
		}
		else
		{
			alert("Lots Cannot Be Empty");
		}
	}
	else
	{
		alert("Tons Field Cannot Be Empty");
	}
}

function dbClick(get_obj)
{
	var form = document.formMain;
	var f_id = get_obj.id;
	form.id.value=f_id;
	form.action_id.value="1";
	form.submit();
}

function doListClick()
{
	var form = document.formMain;
	form.id.value = "0";
	form.action_id.value="0";
	doPost();
}

function doListView()
{
	var form = document.formMain;
	form.action_id.value="0";
	form.action = "trade.fixation.jsp";
	form.submit();
}

function setFirstItemSelected(id,value)
{
	var form = document.formMain;
	var obj = getObj(id);
	if (obj == null) return;	
	obj.options[value].selected = true;
	return;
}

function getTerMth()
{
        var terminal_market = getValue("roll_terminal_market");
        var obj1 = getObj("roll_terminal_month");
        obj1.options.length = 0;
        obj1.options[0] = new Option("");
        obj1.options[0].value = "0";
        obj1.options[0].title = "";

        var date = new Date();
        var curMth = date.getMonth()+1;
        var Yrs = 2005//date.getYear()-1;
        var curYrs = <%=Utils.getCurYear()-1%>;
        numCurYrs = curYrs;
        strCurYrs = numCurYrs.toString();

        var curYrs = strCurYrs.substring(2);
        var loop = 1
        var strMth = "";
        if (terminal_market == "NYC")
        {
                while (loop <= 20)
                {
                        if ((curMth >= 1) && (curMth <= 3))
                        {
                                strMth = "Mar-"+curYrs;
                                curMth = 3;
                        }

                        if ((curMth >= 4) && (curMth <= 5))
                        {
                                strMth = "May-"+curYrs;
                                curMth = 5;
                        }

                        if ((curMth >= 6) && (curMth <= 7))
                        {
                                strMth = "Jul-"+curYrs;
                                curMth = 7;
                        }

                        if ((curMth >= 8) && (curMth <= 9))
                        {
                                strMth = "Sep-"+curYrs;
                                curMth = 9;
                        }

                        if ((curMth >= 10) && (curMth <= 12))
                        {
                                strMth = "Dec-"+curYrs;
                                curMth = 12;
                        }

                        obj1.options[loop] = new Option(strMth);
                        obj1.options[loop].value = "01-" + strMth;
                        obj1.options[loop].title = strMth;

                        if (curMth <= 9)
                        {
                                curMth = curMth+2;
                        }
                        else
                                if (curMth == 9)
                                {
                                        curMth = curMth+3;
                                }
                                else
                                        if (curMth == 12)
                                        {
                                                curMth = 3;
                                                numCurYrs = numCurYrs+1;
                                                strCurYrs = numCurYrs.toString();
                                                curYrs = strCurYrs.substring(2);
                                        }
                        loop=loop+1;
                }

        }
        else
        {
                while (loop <= 24)
                {
                        if ((curMth >= 1) && (curMth <= 2))
                        {
                                strMth = "Jan-"+curYrs;
                                curMth = 1;
                        }

                        if ((curMth >= 3) && (curMth <= 4))
                        {
                                strMth = "Mar-"+curYrs;
                                curMth = 3;
                        }

                        if ((curMth >= 5) && (curMth <= 6))
                        {
                                strMth = "May-"+curYrs;
                                curMth = 5;
                        }

                        if ((curMth >= 7) && (curMth <= 8))
                        {
                                strMth = "Jul-"+curYrs;
                                curMth = 7;
                        }

                        if ((curMth >= 8) && (curMth <= 9))
                        {
                                strMth = "Sep-"+curYrs;
                                curMth = 9;
                        }

                        if ((curMth >= 10) && (curMth <= 11))
                        {
                                strMth = "Nov-"+curYrs;
                                curMth = 11;
                        }

                        obj1.options[loop] = new Option(strMth);
                        obj1.options[loop].value = "01-" + strMth;
                        obj1.options[loop].title = strMth;

                        if (curMth <= 9)
                        {
                                curMth = curMth+2;
                        }
                        else
                                if (curMth == 11)
                                {
                                        curMth = 1;
                                        numCurYrs = numCurYrs+1;
                                        strCurYrs = numCurYrs.toString();
                                        curYrs = strCurYrs.substring(2);
                                }
                        loop=loop+1;
                }
        }
}

function hideunhidebrk()
{
	var form = document.formMain;
	
	if (form.fixation_type.value=="I") hide("BrkId");
	if (form.fixation_type.value=="F") show("BrkId");	
}

function selectRow(obj)
{
	var form = document.formMain;
	form.id.value = obj.id;
	highlightOn(obj);
}
</script>

<style type="text/css">
<!--
.style3 {font-weight: bold}
-->
</style>
<form method="POST" name="formMain" action="" onSubmit="">				  
<table width="100%" border="0" class="style2">
	<tr>
	  <td valign="middle">	    	    <img src="images/pricefixation.jpg" width="250" height="30"> </td>
	</tr>
	<tr><td height="468" valign="top">
    <table width="100%" height="466" border="1" cellpadding="0" cellspacing="0" class="style2">
      <tr valign="top">
	  <td width="121" height="464"><table width="100%">
	  	<tr><td align="center" bgcolor="#EEEEEE" class="style1">Contracts</td>
	  	</tr>
	  	<tr><td height="412" valign="top">
	  		<select name="contracts" size="27" class="style2" id="contracts" style="width:112px; border:0" onChange="doListClick()">
				<%
					task.getResponse().setOption(task.getConditionalList("contract_no","contract_price_type","U","contracts"));
					task.getResponse().setSelected("contracts",focused_id);
				%>
     		</select>
	  	</td></tr>
		<tr><td height="23" align="left" valign="bottom">&nbsp;</td>
		</tr>
	  </table></td>
        <td width="887" align="top"><table width="100%"><tr><td>
<table width="100%" height="185" border="0" class="style2">
        <tr>
          <td width="19%" height="29" align="right">Contract Id</td>
          <td width="1%">&nbsp;</td>
          <td width="17%" class="style1"><label id="contract_id_"><%=rc.getIntValue("id")%></label></td>
		  <input type="hidden" name="contract_id" id = "contract_id"  value="<%=rc.getIntValue("id")%>">
          <td width="2%"><input name="action_id" type="hidden" id="action_id" value="<%=action%>"></td>
		  <%
		  	int strid = rc.getIntValue("id");
		  %>
          <td width="14%" align="right">Terminal Month </td>
          <td width="1%">&nbsp;</td>
		  <%
		  String TerMth="";
		  if (strid == 0)
		  {
		  	 TerMth = rc.getDate("terminal_month");
		  } 
		  else
		  {
		  	//TerMth = rc.getDate("terminal_month").substring(3);
		  }
		  %>
          <td width="11%" class="style1"><label id="terminal_month_"><%=rc.getDate("terminal_month")%></label></td>
		  <input type="hidden" name="ter_month" id = "ter_month"  value="<%=rc.getDate("terminal_month")%>">		
		  <td width="2%">&nbsp;</td>
		  <td width="19%" align="right">Fixed Tons</td>
		  <td width="2%">&nbsp;</td>
          <td width="12%" class="style1"><label id="fixed_tons_"><%=Utils.numberToStr(rc.getFloatValue("fixed_tons"),3)%></label></td>
		  <input type="hidden" name="fixed_tons" id = "fixed_tons"  value="<%=rc.getFloat("fixed_tons")%>">
          </tr>
        <tr>
          <td height="26" align="right">Contract Ref.</td>
          <td>&nbsp;</td>
          <td class="style1"><label id="ref_number_"><%=rc.getString("ref_number")%></label></td>
	      <input type="hidden" name="ref_number_1" id = "ref_number_1"  value="<%=rc.getString("ref_number")%>">
          <td><input name="type" type="hidden" id="type" value="<%=rc.getString("type")%>"></td>
          <td align="right">Differeintial</td>
          <td>&nbsp;</td>
          <td class="style1"><label id="differential_"><%=Utils.numberToStr(rc.getFloatValue("differential"),2)%></label></td>
          <input type="hidden" name="cnt_differential" id = "cnt_differential"  value="<%=rc.getFloatValue("differential")%>">
		  <td>&nbsp;</td>
		  <td align="right">Unfixed Tons</td>
		  <td>&nbsp;</td>

          <td><span class="style1"><label id="unfixed_tons_"><%=Utils.numberToStr(rc.getFloatValue("unfixed_tons"),3)%></label></span></td>
  		  <input type="hidden" name="unfixed_tons" id = "unfixed_tons"  value="<%=rc.getFloat("unfixed_tons")%>">
          </tr>
        <tr>
          <td height="29" align="right">Contract Date</td>
          <td>&nbsp;</td>
          <td class="style1"><label id="contract_date_"><%=rc.getDate("contract_date")%></label></td>
		  <input type="hidden" name="contract_date" id = "contract_date"  value="<%=rc.getDate("contract_date")%>">
          <td><input name="rolling_id" type="hidden" id="rolling_id" value="<%=roll%>"></td>
          <td align="right">Average Price </td>
          <td>&nbsp;</td>
          <td class="style1"><label id="contract_price_foreign_"><%=Utils.numberToStr(rc.getFloatValue("contract_price_foreign"),2)%></label></td>
		  <input type="hidden" name="contract_price_foreign" id = "contract_price_foreign"  value="<%=rc.getFloat("contract_price_foreign")%>">
		  		  
		  <td>&nbsp;</td>
		  <td align="right">Fixed Lots </td>
		  <td>&nbsp;</td>
		  
		  <%
		  		double fix_lot=0;
				double unfix_lot =0;
				
				if (rc.getString("terminal_market").compareTo("LIFFE")==0)
				{
					fix_lot =Utils.strToDouble(rc.getFloat("fixed_tons"))/5;
					unfix_lot=Utils.strToDouble(rc.getFloat("unfixed_tons"))/5;
				}
				else
				{
					fix_lot=Utils.strToDouble(rc.getFloat("fixed_tons"))/17.01;
					unfix_lot=Utils.strToDouble(rc.getFloat("unfixed_tons"))/17.01;
				}
		  %>
          <td width="12%" class="style1"><label id="fixed_lots_"><%=Utils.numberToStr(fix_lot,0)%></label></td>
		  <input type="hidden" name="fixed_lots" id = "fixed_lots"  value="<%=fix_lot%>">
          </tr>
        <tr>
          <td height="29" align="right" class="style2">Supplier / Buyer </td>
          <td class="style3">&nbsp;</td>
          <td class="style1"><label id="supplier_buyer_id_"><%=task.getFieldValueForId("company_master","name",rc.getIntValue("supplier_buyer_id"))%></label></td>
		  <input type="hidden" name="supplier_buyer_id" id = "supplier_buyer_id"  value="<%=rc.getIntValue("supplier_buyer_id")%>">
		  		  
          <td class="style3">&nbsp;</td>
          <td align="right">Contract Tons</td>
          <td class="style3">&nbsp;</td>
          <td class="style1"><label id="tons_"><%=Utils.numberToStr(rc.getFloatValue("tons"),3)%></label></td>
		  <input type="hidden" name="tons" id = "tons"  value="<%=rc.getFloat("tons")%>">
		 
          <td class="style3">&nbsp;</td>
          <td align="right" class="style2">Unfixed Lots </td>
          <td class="style3">&nbsp;</td>
          <td width="12%" class="style1"><label id="unfixed_lots_"><%=Utils.numberToStr(unfix_lot,0)%></label></td>
		  <input type="hidden" name="unfixed_lots" id = "unfixed_lots"  value="<%=unfix_lot%>">
        </tr>
        <tr>
          <td height="29" align="right" class="style2">&nbsp;</td>
          <td class="style3">&nbsp;</td>
          <td class="style1">&nbsp;</td>
          <td class="style3">&nbsp;</td>
          <td align="right">&nbsp;</td>
          <td class="style3">&nbsp;</td>
          <td class="style1">&nbsp;</td>
          <td class="style3">&nbsp;</td>
          <td class="style3">&nbsp;</td>
          <td class="style3">&nbsp;</td>
          <td class="style3">&nbsp;</td>
        </tr>
        <tr align="center">
          <td height="29" colspan="11" class="style2">
		  <table width="75%"  border="1" cellspacing="1" cellpadding="1">
            <tr align="center" bgcolor="#EEEEEE" class="style3">
              <td width="7%" class="style2">Id</td>
              <td width="15%" class="style2">Date</td>
              <td width="15%" class="style2">Tons</td>
              <td width="13%" class="style2">Lots</td>
              <td width="18%" class="style2">Ter.Mth.</td>
              <td width="18%" class="style2">Hedge Price</td>
              <td width="11%" class="style2">Diff</td>
              <td width="12%" class="style2">Price</td>
            </tr>
			<%
				ResultSet Rs = task.fetchFixedList();
				int dLoop=1;
				Rs.beforeFirst();
					while (Rs.next())
					{			
			%>
            			<tr id=<%=Rs.getInt("id")%> onClick="selectRow(this);" onDblClick="dbClick(this);">
              			<td align="left" class="style2">&nbsp;<%=Rs.getInt("id")%></td>
              			<td align="left" class="style2">&nbsp;<%=Utils.dateToStr(Rs.getDate("fixation_date"))%></td>
              			<td align="right" class="style2"><%=Utils.numberToStr(Rs.getFloat("tons_fixed"),3)%>&nbsp;</td>
              			<td align="right" class="style2"><%=Utils.numberToStr(Rs.getFloat("lots_fixed"),0)%>&nbsp;</td>
              			<td align="right" class="style2"><%=Utils.dateToStr(Rs.getDate("terminal_month")).substring(3)%>&nbsp;</td>
              			<td align="right" class="style2"><%=Utils.numberToStr(Rs.getFloat("hedge_price"),2)%>&nbsp;</td>
              			<td align="right" class="style2"><%=Utils.numberToStr(Rs.getFloat("differential"),2)%>&nbsp;</td>
              			<td align="right" class="style2"><%=Utils.numberToStr(Rs.getFloat("price_foreign"),2)%>&nbsp;</td>
            			</tr>
			<%
						dLoop=dLoop+1;
					}
				if (dLoop==1)
				{
			%>
            		<tr>
              			<td align="left">&nbsp;</td>
              			<td align="left">&nbsp;</td>
              			<td align="right">&nbsp;</td>
              			<td align="right">&nbsp;</td>
              			<td align="right">&nbsp;</td>
              			<td align="right">&nbsp;</td>
              			<td align="right">&nbsp;</td>
						<td align="right">&nbsp;</td>
            		</tr>
			<%
				}
			%>			
            <tr>
              <td colspan="8" align="left"><img src="images/new.gif" width="15" height="15" onClick="doAddNew()">&nbsp;<img src="images/delete.gif" width="15" height="15" onClick="doDelete()"></td>
              </tr>			
          </table>        
		  </td>
		  </tr>
</table>
</td></tr>
<tr>
	<td class="style3"><table width="100%">
		<tr>
		  <td valign="middle">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  </tr>
		<tr>
		  <td valign="middle">&nbsp;</td>
		  <td align="center">&nbsp;</td>
		  </tr>
		<tr>
		  <td valign="middle">&nbsp;</td>
		  <td align="center">
		  		<table id="CardEntry" width="80%" border="0" cellspacing="0" cellpadding="0">
            	<tr>
              		<td width="33%" height="24" align="right" class="style2">Date</td>
              		<td width="1%">&nbsp;</td>
              		<td width="66%"><input name="fixation_date" type="text" id="fixation_date" value="<%=fixrc.getDate("fixation_date")%>">
                	<img src="js/calendar.gif" width="20" height="20" onClick="popUpCalendar(this,'fixation_date','dd-mmm-yy');">
                	<input name="id" type="hidden" id="id" value="<%=fixid%>">
                	<input name="fut_ref_no" type="hidden" id="fut_ref_no">
					<input type="hidden" name="differential" id = "differential"  value="<%=fixrc.getFloatValue("differential")%>">            	</tr>
            	<tr>
              		<td height="24" align="right" class="style2">Reference Number </td>
              		<td>&nbsp;</td>
              		<td><input name="ref_number" type="text" id="ref_number" value="<%=fixrc.getString("ref_number")%>" readonly="true"></td>
            	</tr>
            	<tr>
              		<td height="24" align="right" class="style2">Terminal Market</td>
              		<td>&nbsp;</td>
              		<td><input name="terminal_market" type="text" id="terminal_market" value="<%=rc.getString("terminal_market")%>" readonly="true"></td>
            	</tr>
            	<tr>
              		<td height="24" align="right" class="style2">Terminal Month</td>
              		<td>&nbsp;</td>
              		<td><input name="terminal_month" type="text" id="terminal_month" value="<%=fixrc.getDate("terminal_month")%>" readonly="true"></td>
            	</tr>
            	<tr>
              		<td height="24" align="right" class="style2">Lots Fixed</td>
              		<td>&nbsp;</td>
              		<td><input name="lots_fixed" type="text" id="lots_fixed" onChange="doCalTons();" value="<%=Utils.numberToStr(fixrc.getFloatValue("lots_fixed"),0,false)%>"></td>
            	</tr>
            	<tr>
              		<td height="25" align="right" class="style2">Tons Fixed</td>
              		<td>&nbsp;</td>
              		<td><input name="tons_fixed" type="text" id="tons_fixed"  value="<%=Utils.numberToStr(fixrc.getFloatValue("tons_fixed"),3,false)%>"></td>
            	</tr>
            	<tr>
              		<td height="24" align="right" class="style2">Level Fixed </td>
              		<td>&nbsp;</td>
              		<td><input name="hedge_price" type="text" id="hedge_price" onChange="doCalPrice();" value="<%=Utils.numberToStr(fixrc.getFloatValue("hedge_price"),2,false)%>"></td>
            	</tr>
            	<tr>
              		<td height="21" align="right" class="style2">Price</td>
              		<td>&nbsp;</td>
              		<td><input name="price_foreign" type="text" id="price_foreign" value="<%=Utils.numberToStr(fixrc.getFloatValue("price_foreign"),2,false)%>"></td>
            	</tr>
            	<tr>
              		<td align="right" class="style2">Account</td>
              		<td>&nbsp;</td>
              		<td>                
			  	  		<select name="fixation_type" id="fixation_type" style="font-family:Arial; font-size:12; width:33%;" onChange="hideunhidebrk()">
                  		<option value="I">Internal</option>
                  		<option value="F">Futures</option>
                  		<%task.getResponse().setSelected("fixation_type",fixrc.getString("fixation_type"));%>
                  		</select>
					</td>
            	</tr>
            	<tr id="BrkId">
              		<td align="right" class="style2">Futures Account</td>
              		<td>&nbsp;</td>
              		<td><select name="broker_id" id="broker_id" style="font-family:Arial; font-size:12; width:33%;">
                      <option value="0" selected></option>					
                      <option value="1">TRX</option>
                      <%task.getResponse().setSelected("broker_id",fixrc.getString("broker_id"));%>
                    </select></td>
            	</tr>
						<script>
							var form = document.formMain;
							if(form.fixation_type.value == "I") hide("BrkId");
							if(form.fixation_type.value == "F") show("BrkId"); 
						</script>				
            	<tr>
              		<td>&nbsp;</td>
              		<td><img src="images/update.gif" width="15" height="15" onClick="doUpdate()"></td>
              		<td>&nbsp;</td>
            	</tr>
          		</table>
				<script>
					var f = document.formMain;
					if (f.action_id.value=="0")
					{
						hide("CardEntry");
					}
					else
					{
						show("CardEntry");
					}
				</script>
		  </td>
		  </tr>
		<tr>
		  <td valign="middle">&nbsp;</td>
		  <td align="right">&nbsp;</td>
		  </tr>
		<tr>
		  <td valign="middle">&nbsp;</td>
		  <td align="center">
		  		<table id="RollEntry" width="80%" border="0" cellspacing="0" cellpadding="0">
            	<tr>
              		<td width="33%" height="24" align="right" class="style2">Rolling Date</td>
              		<td width="1%">&nbsp;</td>
              		<td width="66%"><input name="rolling_date" type="text" id="rolling_date">
                	<img src="js/calendar.gif" width="20" height="20" onClick="popUpCalendar(this,'rolling_date','dd-mmm-yy');">
                	<input name="roll_id" type="hidden" id="roll_id" value="<%=fixid%>">
                	</td>
            	</tr>
            	<tr>
              		<td height="24" align="right" class="style2">New Terminal Month</td>
              		<td>&nbsp;</td>
              		<td>
						<select name="roll_terminal_month" id="roll_terminal_month" style="font-family:Arial; font-size:12; width:33%;">
                		<script>
		  				getTerMth();
		  	  			</script>
                		<%task.getResponse().setSelected("roll_terminal_month");%>
              			</select>
					</td>
            	</tr>
            	<tr>
              		<td height="24" align="right" class="style2">Lots Rolled</td>
              		<td>&nbsp;</td>
              		<td><input name="lots_rolled" type="text" id="lots_rolled" onChange="doCalTons();"></td>
            	</tr>
            	<tr>
              		<td height="25" align="right" class="style2">Tons Rolled</td>
              		<td>&nbsp;</td>
              		<td><input name="tons_rolled" type="text" id="tons_rolled"></td>
            	</tr>
            	<tr>
              		<td height="21" align="right" class="style2">New Diff </td>
              		<td>&nbsp;</td>
              		<td><input name="new_diff" type="text" id="new_diff"></td>
            	</tr>
            	<tr>
              		<td>&nbsp;</td>
              		<td>&nbsp;</td>
              		<td>&nbsp;</td>
            	</tr>
            	<tr>
              		<td>&nbsp;</td>
              		<td><img src="images/update.gif" width="15" height="15" onClick="doRollUpdate()"></td>
              		<td>&nbsp;</td>
            	</tr>
          		</table>
				<script>
					var g = document.formMain;
					
					if (g.rolling_id.value=="0")
					{
						hide("RollEntry");
					}
					else
					{
						show("RollEntry");
					}
				</script>	
				</td>
		  </tr>
		<tr>
			<td valign="middle">&nbsp;</td>
			<td align="right">&nbsp;</td>
		</tr>
	</table></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
</tr>
</table>
		
		</td>
      </tr>
  </table>
</td></tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
    <tr><td align="right"><img src="images/rollover.jpg" width="55" height="18" onClick="doRoll()">&nbsp;<img src="images/report.jpg" width="55" height="18" onClick="doReport();">&nbsp;<img src="images/listview.jpg" width="55" height="18" onClick="doListView()">&nbsp;</td></tr>
</table>  
	<span class="style3"><input type="hidden" name="uid"        id="uid"       value="<%=user.getuid()%>">		
    <input type="hidden" name="task_id"    id = "task_id"   value="0">
  </span>
</form>  
<span class="style3"><%
	rc.close();
%>
<%@include file="../footer.jsp"%>

</span>